import apiRequest from '@/plugins/apiRequest.js';
// 系统配置
const ENV_CONFIG = uni.envConfig;
// 接口的基础路径
const apiContextPath = ENV_CONFIG.baseUrl+"/supervisor";
export const apiContextPathSsbd = ENV_CONFIG.baseUrlSsbd;
import my from "./my"
import task from "./task"
// import home from "./home"
// import merchant from "./merchant"
/**
 * 接口模块
 */


/**
 * 接口请求管理
 */
const api = {
	/**
	 * 公用
	 */
	common: {
		//文件上传
		uploadFile(data) {
			console.log("uploadFile=", data)
			let file = data.file
			return apiRequest.upload(
				apiContextPathSsbd + 'api/file/formImage',
				file,
			);
		}
	},
	/**
	 * 首页
	 */
	index: {
		//获取达人橱窗授权状态
		getPromoterStatus(data) {
			return apiRequest.post(
				apiContextPathSsbd + 'api/wechatAlliance/getPromoterStatus',
				data, {
					header: {
						'Content-Type': 'application/x-www-form-urlencoded'
					}
				}
			);
		},
		  //获取达人授权链接
		getAuthorizePromoter(data) {
			return apiRequest.post(
				apiContextPathSsbd + 'api/wechatAlliance/authorizePromoter',
				data, {
					header: {
						'Content-Type': 'application/x-www-form-urlencoded'
					}
				}
			);
		},
		//添加商品到橱窗
		addProduct(data) {
			return apiRequest.post(
				apiContextPathSsbd + 'api/wechatAlliance/addProduct',
				data, {
					header: {
						'Content-Type': 'application/x-www-form-urlencoded'
					}
				}
			);
		},
		//队列商品
		wechatstoreQueue(page, pageSize) {
			return apiRequest.get(
				apiContextPathSsbd + 'api/wechatstoreQueue/lists?page=' + page + '&page_size=' + pageSize,{
					header: {
						'Content-Type': 'application/x-www-form-urlencoded'
					}
				}
			);
		},
		//填写邀请码绑定上级
		distributionCode(data) {
			return apiRequest.post(
				apiContextPathSsbd + 'api/distribution/code',
				data, {
					header: {
						'Content-Type': 'application/x-www-form-urlencoded'
					}
				}
			);
		}
	},

	/**
	 * 用户鉴权相关 模块
	 */
	user: {
		/**
		 * 登录
		 * @param data { username: '', password: '', }
		 */
		login(data) {
			return apiRequest.post(
				apiContextPathSsbd + 'api/account/authLogin',
				data, {
					header: {
						'Content-Type': 'application/x-www-form-urlencoded'
					}
				}
			);
		},
		/**
		 * 注册
		 * 
		 */
		register(data) {
			return apiRequest.post(
				apiContextPathSsbd + '/fast/user/addUser',
				data
			);
		},

	},

};
let allApi = Object.assign({}, api, my, task)
export default allApi;
